<template>
	<view>
		<view class="setting_box main-box-style">
			<view class="item" @click="changeinfo" v-if="shenfen==2">
				<view class="item_left">
					<image src="../static/one.jpg" class="u-m-r-20" mode=""></image>
					<text>更改收货信息</text>
				</view>
				<u-icon name='arrow-right'></u-icon>
			</view>
			<view class="item u-m-t-40" @click="$goTo('/pages/myallorder/myallorder')" v-if="shenfen==2">
				<view class="item_left">
					<image src="../static/two.jpg" class="u-m-r-20" mode=""></image>
					<text>我的所有订单</text>
				</view>
				<u-icon name='arrow-right'></u-icon>
			</view>
			<view class="item u-m-t-40">
				<view class="item_left">
					<image src="../static/three.jpg" class="u-m-r-20" mode=""></image>
					<button open-type="contact" bindcontact="handleContact" session-from="sessionFrom">联系客服</button>

				</view>
				<u-icon name='arrow-right'></u-icon>
			</view>
		</view>

		<view class="setting_box main-box-style u-m-t-20">
			<view class="item" @click="$goTo('/pages/mybag/mybag')" v-if="shenfen==2">
				<view class="item_left">
					<image src="../static/four.jpg" class="u-m-r-20" mode=""></image>
					<text>我的钱包</text>
				</view>
				<u-icon name='arrow-right'></u-icon>
			</view>
			<!-- 	<view class="item u-m-t-40">
				<view class="item_left">
					<image src="../static/logo.png" class="u-m-r-20" mode=""></image>
					<text>更改收货信息</text>
				</view>
				<u-icon name='arrow-right'></u-icon>
			</view> -->
			<view class="item u-m-t-40" v-if="shenfen==3">
				<view class="item_left">
					<image src="../static/five.jpg" class="u-m-r-20" mode=""></image>
					<text>营业打样</text>
				</view>
				<view class="switchbox">
					<text>休息 </text>
					<u-switch v-model="value" @change="change"></u-switch>
					<text> 营业</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "setting",
		data() {
			return {
				value: false,
				shenfen: ''
			};
		},
		mounted() {
			this.init()
			console.log('123123123');
		},
		methods: {
			init() {
				this.$userinfo().then(res => {
					this.value = res.data.data.is_dy == 1 ? true : false
					this.shenfen = res.data.data.group_id
				})
			},
			change(e) {
				console.log(e);
				this.open()
			},
			handleContact(e) {
				console.log(e.detail.path)
				console.log(e.detail.query)
			},
			changeinfo() {
				this.$emit('changeinfo', true)
			},
			open() {
				this.$api.post('/user/Upmyinfo', {
					is_dy: this.value ? 1 : 0
				}).then(res => {
					this.$toast(res.msg)
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.setting_box {
		background-color: #fff;

		.item {
			display: flex;
			align-items: center;
			justify-content: space-between;

			.item_left {
				display: flex;
				align-items: center;

				image {
					width: 50rpx;
					height: 50rpx;
				}

				
			}

			.switchbox {
				display: flex;
				align-items: center;
			}
		}
	}
	::v-deep button {
		position: relative;
		display: block;
		margin-left: auto;
		margin-right: auto;
		padding-left: 0px !important;
		padding-right: 14px;
		box-sizing: border-box;
		font-size: 16px !important;
		text-align: center;
		text-decoration: none;
		// line-height: 2.55555556;
		border-radius: 5px;
		-webkit-tap-highlight-color: transparent;
		overflow: hidden;
		color: #000;
		background-color: #fff;
		cursor: pointer;
		border: 0

	}
	
	::v-deep button:after {
		content: " ";
		width: 0%;
		height: 0%;
		position: absolute;
		top: 0;
		left: 0;
		border: 1px solid rgba(0, 0, 0, .2);
		-webkit-transform: scale(.5);
		transform: scale(.5);
		-webkit-transform-origin: 0 0;
		transform-origin: 0 0;
		box-sizing: border-box;
		border-radius: 10px;
	}
</style>